<!DOCTYPE html>
<html>

<head>
    <title>PDF Annotation And Drawing Markup Plugin</title>

    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
        integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.css">
    <link rel="stylesheet" href="pdfAnnotator.css">
</head>

<body>
    <div class="sidebar">
        <ul class="sidebarList">
            <li class="logoTitle">Fellowmark.</li>
            <li class="sidebarRow" onclick="navigateHome(window.localStorage.getItem('userRole'))">
                <div id="icon"><img src="images/homeLogo.png" width="20" height="20"></div>
                <div id="title">Home</div>
            </li>
            <li class="sidebarRow" onclick="navigateModule(window.localStorage.getItem('userRole'))">
                <div id="icon"><img src="images/moduleLogo.png" width="20" height="20"></div>
                <div id="title">Modules</div>
            </li>
            <li class="sidebarRow" onclick="logoutUser(window.localStorage.getItem('satoken'))">
                <div id="icon"><img src="images/logoutLogo.png" width="20" height="20"></div>
                <div id="title">Logout</div>
            </li>
        </ul>
    </div>

    <div class="toolbar">
        <div class="tool">
            <button class="btn btn-light btn-sm" style="color: green;" onclick="exit();">Exit</button>
        </div>
    </div>

    <div id="pdf-container"></div>

    <div class="modal fade" id="dataModal" tabindex="-1" role="dialog" aria-labelledby="dataModalLabel"
        aria-hidden="true">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">

                <div class="modal-header">
                    <h5 class="modal-title" id="dataModalLabel">PDF annotation JSON data</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">×</span>
                    </button>
                </div>

                <div class="modal-body">
                    <pre class="prettyprint lang-json linenums"></pre>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"
        integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN"
        crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"
        integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV"
        crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.6.347/pdf.min.js"></script>
    <script>pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.6.347/pdf.worker.min.js';</script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/4.3.0/fabric.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.2.0/jspdf.umd.min.js"></script>
    <script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.js"></script>
    <script src="pdfViewer.js" defer></script>

    <script>
        function navigateHome(userRole){
            if (userRole === 'stu') {
                window.location.pathname = '/student/home'
            }
            if (userRole === 'staff') {
                window.location.pathname = '/staff/home'
            }
        }
        function navigateModule(userRole){
            if (userRole === 'stu') {
                window.location.pathname = '/student/module'
            }
            if (userRole === 'staff') {
                window.location.pathname = '/staff/module'
            }
        }
        function logoutUser(satoken){
            fetch('http://localhost:8080/user/logout', {
                method: 'GET',
                headers: { "satoken": satoken },
            })
            .then(() => {
                window.history.pushState(null, null, window.location.href = '/login');
                window.history.go(1);
            })
        }
    </script>

</body>

</html>